<template>
<!-- 添加或修改文章对话框 -->
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="文章标题" prop="title">
          <el-input v-model="form.title" placeholder="请输入文章标题" />
        </el-form-item>
        <el-form-item label="文章分类" prop="categorieId">
          <el-input v-model="form.categorieId" placeholder="请输入文章分类" />
        </el-form-item>
        <el-form-item label="文章标签" prop="tagId">
          <el-input v-model="form.tagId" placeholder="请输入文章标签" />
        </el-form-item>
        <el-form-item label="文章的URL别名，唯一标识" prop="slug">
          <el-input v-model="form.slug" placeholder="请输入文章的URL别名，唯一标识" />
        </el-form-item>
        <el-form-item label="文章内容">
          <!-- <editor v-model="form.content" :min-height="192"/> -->
           <tinymce v-model="form.content"/>
        </el-form-item>
        <el-form-item label="发表该文章的用户ID，关联到Users表的user_id" prop="userId">
          <el-input v-model="form.userId" placeholder="请输入发表该文章的用户ID，关联到Users表的user_id" />
        </el-form-item>
        <el-form-item label="文章发表时间" prop="publishedAt">
          <el-date-picker clearable
            v-model="form.publishedAt"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择文章发表时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="文章最后更新时间" prop="updatedAt">
          <el-date-picker clearable
            v-model="form.updatedAt"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择文章最后更新时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="文章被查看的次数" prop="viewCount">
          <el-input v-model="form.viewCount" placeholder="请输入文章被查看的次数" />
        </el-form-item>
        <el-form-item label="文章被点赞的次数" prop="likeCount">
          <el-input v-model="form.likeCount" placeholder="请输入文章被点赞的次数" />
        </el-form-item>
        <el-button type="primary" @click="submitForm">确 定</el-button>
      </el-form>
      <!-- <div>
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div> -->
</template>
<script>
import { addBlogPosts, updateBlogPosts } from "@/api/blog/blogPosts";
import tinymce from "@/components/Tinymce";
export default {
    mounted() {
    this.form=this.$route.params.form; // 输出 "123"
  },
  components:{
    tinymce
  },
  data() {
    return {
        rules: {
        },
        form:{},
    }
},
methods: {
/** 提交按钮 */
submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.postId != null) {
            updateBlogPosts(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              // this.open = false;
              // this.getList();
            });
          } else {
            addBlogPosts(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              // this.open = false;
              // this.getList();
            });
          }
        }
      });
    },

}
}
</script>
<style>
</style>